<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Course Details</f:facet>

        <s:decorate id="id" template="layout/display.xhtml">
            <ui:define name="label">Id</ui:define>
            <h:outputText value="#{courseHome.instance.id}"/>
        </s:decorate>

        <s:decorate id="courseName" template="layout/display.xhtml">
            <ui:define name="label">Course name</ui:define>
            <h:outputText value="#{courseHome.instance.courseName}"/>
        </s:decorate>

        <s:decorate id="details" template="layout/display.xhtml">
            <ui:define name="label">Details</ui:define>
            <h:outputText value="#{courseHome.instance.details}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/CourseEdit.xhtml"
                    id="edit"
                 value="Edit"/>

        <s:button view="/#{empty courseFrom ? 'CourseList' : courseFrom}.xhtml"
                    id="done"
                 value="Done"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Teacher</h:panelGroup>
        </f:facet>
    <div class="association" id="teacherParent">

        <h:outputText value="There is no teacher associated with this course."
                   rendered="#{courseHome.instance.teacher == null}"/>

        <rich:dataTable var="_teacher"
                   value="#{courseHome.instance.teacher}"
                rendered="#{courseHome.instance.teacher != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="teacherTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_teacher.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccount id</f:facet>
                <h:outputText value="#{_teacher.userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address by present address id id</f:facet>
                <h:outputText value="#{_teacher.addressByPresentAddressId.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address by permanent address id id</f:facet>
                <h:outputText value="#{_teacher.addressByPermanentAddressId.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">First name</f:facet>
                <h:outputText value="#{_teacher.firstName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Last name</f:facet>
                <h:outputText value="#{_teacher.lastName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Passport photo url</f:facet>
                <h:outputText value="#{_teacher.passportPhotoUrl}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Subject</f:facet>
                <h:outputText value="#{_teacher.subject}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Date of birth</f:facet>
                <h:outputText value="#{_teacher.dateOfBirth}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Qualification</f:facet>
                <h:outputText value="#{_teacher.qualification}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Mobile number</f:facet>
                <h:outputText value="#{_teacher.mobileNumber}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Contact number in case of emergency</f:facet>
                <h:outputText value="#{_teacher.contactNumberInCaseOfEmergency}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Comments</f:facet>
                <h:outputText value="#{_teacher.comments}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewteacher"
                     value="View"
                      view="/Teacher.xhtml">
                    <f:param name="teacherId"
                           value="#{_teacher.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Students</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="studentsChildren">

        <h:outputText value="There are no students associated with this course."
                   rendered="#{empty courseHome.students}"/>

        <rich:dataTable value="#{courseHome.students}"
                       var="_student"
                  rendered="#{not empty courseHome.students}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="studentsTable">
            <rich:column sortBy="#{_student.id}">
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_student.id}"/>
            </rich:column>
            <rich:column sortBy="#{_student.firstName}">
                <f:facet name="header">First name</f:facet>
                <h:outputText value="#{_student.firstName}"/>
            </rich:column>
            <rich:column sortBy="#{_student.lastName}">
                <f:facet name="header">Last name</f:facet>
                <h:outputText value="#{_student.lastName}"/>
            </rich:column>
            <rich:column sortBy="#{_student.passportPhotoUrl}">
                <f:facet name="header">Passport photo url</f:facet>
                <h:outputText value="#{_student.passportPhotoUrl}"/>
            </rich:column>
            <rich:column sortBy="#{_student.dateOfBirth}">
                <f:facet name="header">Date of birth</f:facet>
                <h:outputText value="#{_student.dateOfBirth}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </rich:column>
            <rich:column sortBy="#{_student.registerNumber}">
                <f:facet name="header">Register number</f:facet>
                <h:outputText value="#{_student.registerNumber}"/>
            </rich:column>
            <rich:column sortBy="#{_student.rollNumber}">
                <f:facet name="header">Roll number</f:facet>
                <h:outputText value="#{_student.rollNumber}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectstudent"
                     value="Select"
                      view="/Student.xhtml">
                    <f:param name="studentId"
                            value="#{_student.id}"/>
                    <f:param name="studentFrom" value="Course"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add student"
                view="/StudentEdit.xhtml">
            <f:param name="courseId"
                    value="#{courseHome.instance.id}"/>
            <f:param name="studentFrom" value="Course"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
